package com.example.controller;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.example.common.result.Result;
import com.example.entity.dto.ApprovalProcessDto;
import com.example.entity.mysql.ApprovalProcess;
import com.example.service.ApprovalProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 审批流程名称表 前端控制器
 * </p>
 *
 * @author LiangPandeng
 * @since 2024-02-22
 */
//@RestController
////@RequestMapping("/approval-process")
//@Api(tags = "审批流程名称表接口")
//@Slf4j
public class ApprovalProcessController {

//    @Resource
//    private ApprovalProcessService approvalProcessService;
//
//    @DS("mysql")
//    @PostMapping("/add")
//    @ApiOperation("审批流程名称表添加")
//    public Result add(@RequestBody ApprovalProcess approvalProcess){
//        approvalProcess.setUuid(null);
//        boolean save = approvalProcessService.save(approvalProcess);
//        if (save == true) return Result.success();
//        else return  Result.error("保存失败！ ");
//    }
//
//    @DS("mysql")
//    @DeleteMapping("/updateState")
//    @ApiOperation("审批流程名称表状态修改")
//    public Result updateState(Integer uuid){
//        ApprovalProcess approvalProcess = approvalProcessService.getById(uuid);
//        UpdateWrapper<ApprovalProcess> updateWrapper = new UpdateWrapper<>();
//        updateWrapper.eq("uuid",uuid);
//        updateWrapper.set("State",approvalProcess.getState().equals("1")?"0":"1");
//        boolean update = approvalProcessService.update(null, updateWrapper);
//
//        if (update == true) return Result.success("修改成功");
//        else return  Result.error("修改失败！ ");
//    }
//
//    @DS("mysql")
//    @ApiOperation("审批流程名称表查询")
//    @GetMapping("/select")
//    public Result<List<ApprovalProcess>> select( ApprovalProcessDto approvalProcessDto){
//        QueryWrapper<ApprovalProcess>  queryWrapper = new QueryWrapper<>();
//        if (StringUtils.isNotBlank(approvalProcessDto.getApprovalProcessName()))
//            queryWrapper.like("approval_process_name",approvalProcessDto.getApprovalProcessName());
//
//        if (StringUtils.isNotBlank(approvalProcessDto.getCreator()))
//            queryWrapper.like("creator",approvalProcessDto.getCreator());
//
//        if ( approvalProcessDto.getApprovalProcessLength() != null && approvalProcessDto.getApprovalProcessLength() >0)
//            queryWrapper.eq("approval_process_length",approvalProcessDto.getApprovalProcessLength());
//
//        queryWrapper.orderByDesc("approval_process_name");
//
//        List<ApprovalProcess> approvalProcessList = approvalProcessService.list(queryWrapper);
//        return Result.success(approvalProcessList);
//    }



}
